package mvpfoot.ui;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.example.click.mvpfoot.R;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import mvpfoot.BaseActivity;
import mvpfoot.adapter.PersonINfoAdapter;
import mvpfoot.entity.User;
import mvpfoot.entity.ZhihuStory;
import mvpfoot.iViewBind.IPersonView;
import mvpfoot.presenter.DownLoadPresenter;

public class PersonCenterActivity extends BaseActivity implements View.OnClickListener, IPersonView {

    @InjectView(R.id.toolbar)
    Toolbar toolbar;
    @InjectView(R.id.button)
    Button button;
    @InjectView(R.id.recycleview)
    RecyclerView recycleview;
    private DownLoadPresenter downLoadPresenter = new DownLoadPresenter(this);
    private String TAG = "USername";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_person_center);
        ButterKnife.inject(this);
        toolbar.setNavigationIcon(R.mipmap.ic_launcher);
        toolbar.setTitle("dasdasdf");
        button.setOnClickListener(this);
        toolbar.inflateMenu(R.menu.menu);
        Log.d(TAG, "onClick() called with: " + "v = [" + User.getInstance().getName() + "]");
        downLoadPresenter.loadNetworkInfo();
    }

    @Override
    public void onClick(View v) {
        Log.d(TAG, "onClick() called with: " + "v = [" + User.getInstance().getName() + "]");
        User.reset();
        Log.d(TAG, "onClick() called with: " + "v = [" + User.getInstance().getName() + "]");
        finish();
        //downLoadPresenter.upload("dasda");
    }

    @Override
    public void LoadSuccess(List<ZhihuStory> newsLists) {
        PersonINfoAdapter adapter=new PersonINfoAdapter(newsLists);
        recycleview.setHasFixedSize(true);
        recycleview.setLayoutManager(new StaggeredGridLayoutManager(2,LinearLayoutManager.VERTICAL));
        recycleview.setAdapter(adapter);
    }
}